package mt;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author zhangmin
 * @create 2022-03-26 15:47
 */
public class meituan_0326_1 {

    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        String line=cin.nextLine();
        Map<Character,Integer> map1=new HashMap<>();
        map1.put('a',2);
        map1.put('c',3);
        map1.put('b',1);
        Map<Character,Integer> map2=new HashMap<>();
        for (char c:line.toCharArray()) {
            if (map1.containsKey(c)){
                map2.put(c,map2.getOrDefault(c,0)+1);
            }
        }
        int res=Integer.MAX_VALUE;
        for (char c= 'a';  c<='c' ; c++) {
            res=Math.min(res,(map2.get(c)/map1.get(c)));
        }
        System.out.println(res);
    }
}
